package com.smzd.framework.system.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smzd.core.dao.IDao;
import com.smzd.framework.core.business.AbstractFGService;
import com.smzd.framework.system.dao.UserBindDao;
import com.smzd.framework.system.domain.UserBind;
import com.smzd.framework.utils.db.FGRowConverter;

@Service
public class UserBindService extends AbstractFGService<UserBind> {
    @Autowired
    private UserBindDao dao;
    
    @Override
    protected IDao<UserBind> getDao() {
        return dao;
    }
    
    @Override
    public FGRowConverter<UserBind> getConverter() {
        return converter;
    }

    private static FGRowConverter<UserBind> converter = new FGRowConverter<UserBind>() {
        @Override
        public Object[] convert(UserBind elem) {
            Object[] fs = new Object[]{
                    elem.getId(),
                    elem.getName(),
                    elem.getDescription(),
                    elem.getOpenid(),
                    elem.getAvatar(),
                    elem.getUrl(),
                    elem.getDomain(),
                    elem.getType()
                };
                return fs;
        }
    };
    
    public UserBind getUserBindByOpenid(String openid){
        return dao.getUserBindByOpenid(openid);
    }
    
    public List<UserBind> getUserBindsByUserId(int userId){
        return dao.getUserBindsByUserId(userId);
    }

	public UserBind getUserBindBySocial(int userId, int sid) {
		return dao.getUserBindBySocial(userId, sid);
	}
    
}